public class WaitTask implements Runnable{
    private Object object;
    public WaitTask(Object object) {
        this.object = object;
    }

    @Override
    public void run() {
        synchronized (object) {
            while (true) {
                try {
                    System.out.println("wait开始"+Thread.currentThread().getName());
                    object.wait();
                    System.out.println("wait结束"+Thread.currentThread().getName());
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
